package com.aaa.order.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * fileName:OrderDao
 * description:
 * author:xjf
 * createTime:2020/1/7 9:08
 * version:1.0.0
 */
public interface OrderDao {
    /**
     * 订单列表查询
     * @param map
     * @return
     */
    @Select({"<script>" +
            "select * from oms_order" +
            "<where> member_id = #{memberId} </where>" +
            "<when test='shop_id!=null'> and shop_id= #{shopId} </when>" +
            "</script>"})
    List<Map> getListByParam(Map map);

    /**
     * 添加订单
     * @param map
     * @return
     */
    @Insert("insert into oms_order(member_id,shop_id,order_sn,create_time,member_username,total_amount,pay_amount,receiver_name,receiver_phone,delete_status)" +
            "VALUES(#{memberId},#{shopId},#{orderSn},sysdate(),#{memberUsername},#{totalAmount},#{payAmount},#{receiverName},#{receiverPhone},#{deleteStatus})")
    int add(Map map);

    /**
     * 修改订单
     * @param map
     * @return
     */
    @Update({"<script>" +
            "update oms_order SET status= #{status}," +
            "receiver_name=#{receiverName}," +
            "receiver_phone=#{receiverPhone}," +
            "confirm_status=#{confirmStatus}," +
            "delete_status=#{deleteStatus}" +
            "where id= #{Id}" +
            "</script>"})
    int update(Map map);

    /**
     * 删除订单
     * @param map
     * @return
     */
    @Delete("delete  from oms_order where id=#{Id}")
    int delete(Map map);


}
